package com.chenxi.service.impl;

import com.chenxi.mapper.UserMapper;
import com.chenxi.model.User;
import com.chenxi.service.UserServiceI;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("userService")
public class UserServiceImpl implements UserServiceI {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User getById(Long id) {
        return userMapper.getById(id);
    }

    @Override
    public List<User> find(Map<String,Object> param) {
        return userMapper.find();
    }

    @Override
    public void save(User u) {
        userMapper.insert(u);
    }

    @Override
    public void update(User u) {
        userMapper.updateByPrimaryKey(u);

    }

    @Override
    public void delete(User u) {
        userMapper.delete(u);
    }

    @Override
    public Page<User> page(Map<String,Object> param) {
        List<User> list = userMapper.find();

        return (Page<User>) list;
    }


}
